package com.happy.controller.api;


import com.happy.Test.TestBean;
import com.happy.utils.JSONUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api/test")
public class TestController {

    public static String test = "{\"id\":1,\"name\":\"zhangsan\"}";

    @ResponseBody
    @RequestMapping("/test1")
    public String test1() {

        String test = JSONUtils.O2J(new TestBean(1, "zhangsan"));
        System.out.println(test);
        return test;
    }

    @ResponseBody
    @RequestMapping("/test2")
    public String test2() {

        TestBean testBean = JSONUtils.J2O(TestController.test, TestBean.class);
        System.out.println(testBean.getId());
        System.out.println(testBean.getName());

        return "hello";
    }


}
